﻿@model IEnumerable<LocalizationItem>
@{
    var languages = ViewBag.Languages;
    if(languages == null && this.Model != null)
    {
        languages = this.Model.Select(o => string.IsNullOrWhiteSpace(o.CultureInfo) ? "Default" : o.CultureInfo).Distinct();
    }
}
<script type="text/javascript">
    function DeleteLang() {
        var formId = $('#localDiv div:visible form').attr('id');
        Delete(formId, '/Admin/Local/Delete');
    }
</script>
<div>
    <ul>
        <li><a href="/Admin/Local/Index" class="selected">用户资源</a></li>
        <li><a href="/Admin/JsonLocal/Index">系统资源</a></li>
    </ul>
</div>
@if (this.Model != null)
{
    <div id="localDiv" class="tabs">
        <ul>
            @foreach (var lang in languages)
            {
                <li><a href="#@lang">@lang</a></li>
            }
        </ul>
        @foreach (var lang in languages)
        {
            <div id="@lang">
                <h3>
                    Language: @lang</h3>
                @{ Html.BeginForm("Delete", null, FormMethod.Post, new { id = lang + "-list-form", name = lang + "-list-form" });
                }
                <table id="list-table" class="list-table" cellpadding="0" cellspacing="0" border="0">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" onclick="if(this.checked) { $('#@lang-list-form input:checkbox').attr('checked', 'checked'); } else { $('#@lang-list-form input:checkbox').removeAttr('checked'); }" />
                            </th>
                            <th>
                                AssemblyName
                            </th>
                            <th>
                                Resource
                            </th>
                            <th>
                                Value
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var res in this.Model.Where(o => o.CultureInfo == lang))
                        {
                            var key = string.Format("{0}${1}${2}", res.AssemblyName, lang, res.Name);
                            <tr>
                                <td>
                                    <input type="checkbox" id="cb_@(key)" name="cb_@(key)" value="@key" />
                                </td>
                                <td>@res.AssemblyName
                                </td>
                                <td>@res.Name
                                </td>
                                <td>@res.Value
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                @{Html.EndForm();
                }
            </div>
        }
    </div>
}
